﻿using Google.Protobuf.WellKnownTypes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Textbook
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }
        public Login(Home home)
        {
            InitializeComponent();
            this.home = home;
        }

        Home home;

        SQL sql = new SQL();

        private void sure_Click(object sender, EventArgs e)
        {
            if (s.Checked)
            {
                Students students = sql.stuLogin(id.Text, pass.Text);
                if (students.S_id != "")
                {
                    home.openForm(new StuForm(home, students));
                }
                else
                {
                     MessageBox.Show("账号或密码错误...");
                }
            }
            else if(t.Checked)
            {

                Teacher teacher = sql.teaLogin(id.Text, pass.Text);
                if (teacher.T_id != "")
                {
                    home.openForm(new TeaForm(home, teacher));
                }
                else
                {
                    MessageBox.Show("账号或密码错误...");
                }
            }
            else if (i.Checked)
            {
                Issue issue = sql.issLogin(id.Text, pass.Text);
                if (issue.I_id != "")
                {
                    home.openForm(new IssForm(home, issue));
                }
                else
                {
                    MessageBox.Show("账号或密码错误...");
                }
            }
            else
            {
                Procure procure = sql.proLogin(id.Text, pass.Text);
                if (procure.P_id != "")
                {
                    home.openForm(new ProForm(home, procure));
                }
                else
                {
                    MessageBox.Show("账号或密码错误...");
                }
            }
        }
    }
}
